package org.jeecg.modules.miniAppCustomerEndPoint.utils;

import org.geotools.referencing.GeodeticCalculator;
import org.geotools.referencing.crs.DefaultGeographicCRS;

public class GeoUtil {

    public static double getDistance(double longitude1, double latitude1, double longitude2, double latitude2) {
        // 84坐标系构造GeodeticCalculator
        GeodeticCalculator geodeticCalculator = new GeodeticCalculator(DefaultGeographicCRS.WGS84);
        // 起点经纬度
        geodeticCalculator.setStartingGeographicPoint(longitude1, latitude1);
        // 末点经纬度
        geodeticCalculator.setDestinationGeographicPoint(longitude2, latitude2);
        // 计算距离，单位：米
        return geodeticCalculator.getOrthodromicDistance();
    }
}
